<?php
	session_start();

	if (!isset($_SESSION['login']) && !$_SESSION['login'] == true) {
		header ("Location: index.php");
	}
	
	if(isset($_GET['ID']))
	{
		include ("config.php");

		$ToUpdate = $_GET['ID'];
		$employeename = $_POST['employeename'];
		$employeelogin = $_POST['employeelogin'];
		$supervisorID = $_POST['supervisorID'];
		
		$_SESSION['Popup'] = $employeename;
		$_SESSION['MessageKey']="saved";
		
		$stmt = $con->prepare('UPDATE User SET Name =  ?, Login = ?, SupervisorID = ? WHERE ID = ?');
		$stmt->bind_param('ssii', $employeename, $employeelogin, $supervisorID, $ToUpdate);
		$stmt->execute();
		
		mysqli_close($con);
		
		header ("Location: listusers.php");
	}
	else
		header ("Location: listusers.php");
?>